<template>
	<!-- 团购订单   -->
	<view class="exchangeorderr_wp">
		<view class="e_list">
			<view class="e_item" v-for="(item,idx) in list" :key="item.id"
				@click="$navTo('/pages/product/groupbuy?id='+item.goodsList[0].goodsid)">
				<view class="order_info">
					<view class="title clamp">{{item.supname}} ></view>
					<text class="o_status">{{item.statusName}}</text>
				</view>
				<view class="goods_info">
					<image class="goods-img" :src="item.goodsList[0].thumb" mode="aspectFill"></image>
					<view class="right">
						<view class="sattus2 clamp">{{item.goodsList[0].goodstitle}}</view>
						<view class="g_pay">营业时间可用</view>
						<view class="g_pay">订单编号：{{item.ordersn}}</view>
					</view>
					<view class="g_price">
						<text class="small">￥</text><text class="price">{{item.goodsList[0].goodsprice}}</text>
					</view>
				</view>
				<view class="order_youhui" v-if="item.discountprice!='0.00'">
					<view class="left">
						<image src="/static/youhui.png" mode="widthFix"></image>
						<text>多米街支付优惠</text>
					</view>
					<text>-￥{{item.discountprice.toFixed(2)}}</text>
				</view>
				<view class="time">
					<view class="p_time p_daojishi" v-if="item.status==0"><uni-countdown :font-size="10" color="#AF141D" :show-hour="false" :show-day="false" :minute="minute(item.lasttime)" :second="second(item.lasttime)"></uni-countdown>后订单取消</view>
					<text class="p_time" v-else>{{item.paytime}}</text>
					<view>共计{{item.goodsList[0].total}}件商品 实付：<text class="small">￥</text><text class="price">{{item.price}}</text></view>
				</view>
				<view class="btns">
					<view class="border" v-if="item.status==0" @click.stop="cancelOrder(item.id,idx)">取消订单</view>
					<view class="border long" v-if="barIdx1==2&&typeIdx2==1" @click.stop="$navTo('/pages/order/detailsw?id='+item.id)">核销码/退款</view>
					<view class="border" v-else @click.stop="$navTo('/pages/order/detailsw?id='+item.id)">订单详情</view>
					<view class="border" v-if="item.status==0" @click.stop="$navTo('/pages/money/pay?orderid='+item.id)">立即支付</view>
					<view class="border" v-if="item.status>1&&item.evaluate==0" @click.stop="$navTo('/pages/order/evaluate?id='+item.id)">去评价</view>
					<view class="bg" v-if="item.status>1" @click.stop="$navTo('/pages/product/groupbuy?id='+item.goodsList[0].goodsid)">再来一单</view>
				</view>
			</view>
			<view class="empty_loading">
				<image v-if="isloading" src="/static/business/loading.gif" ></image>
				<text v-if="ismore">到底了~</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'myorder',
		props: {
			list: {
				type: Array,
				default: () => []
			},
			isloading: {
				type: Boolean,
				default: false
			},
			ismore: {
				type: Boolean,
				default: true
			},
			barIdx1: {
				type: Number,
				default: 0
			},
			typeIdx2: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				active: 1,
			}
		},
		methods: {
			second(v) {
				return Math.trunc(v % 60);
			},
			minute(v) {
				return Math.trunc(v / 60 % 60);
			},
			hour(v) {
				return Math.trunc(v / 60 / 60 % 24);
			},
			cancelOrder(v, idx) {
				this.$axios('Op/cancel', 'POST', 'order', {
					orderid: v
				}).then(res => {
					if (res.data.code == 200) {
						let list = [...this.list];
						list.splice(idx, 2);
						this.$emit('update:list', list);
						this.$api.msg('已取消订单！');
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #f2f2f2;
		color: $font-color-dark;
		padding-bottom: 130upx;
	}

	.e_nav {
		background-color: #fff;
		display: flex;
		align-items: center;
		line-height: 100upx;
		position: fixed;
		width: 100%;
		z-index: 100;
	}

	.e_nav view {
		flex: 1;
		text-align: center;
		font-size: $font-base;
		position: relative;
	}

	.e_nav_active:after {
		content: '';
		border-bottom: 3px $base-color solid;
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
		bottom: 20upx;
		width: 40upx;
	}

	.e_list {
		overflow: hidden;
	}

	.e_item {
		background-color: #fff;
		border-radius: 10upx;
		margin: 20upx 20upx 0;
		padding: 20upx;
		.order_info{
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-weight: 600;
			border-bottom: 1rpx solid #E9E9E9;
			padding-bottom: 20rpx;
			.title{
				font-size: 28rpx;
				color: #333333;
			}
			.o_status{
				font-size: 24rpx;
				color: #8615E1;
			}
		}
		.goods_info{
			align-items: center;
			display: flex;
			justify-content: space-between;
			margin: 20rpx 0;
			image {
				border-radius: 10upx;
				height: 120upx;
				width: 120upx;
			}
			
			.right {
				padding-left: 20upx;
				line-height: 40upx;
				width: calc(100% - 280rpx);
			
				.sattus2 {
					font-size: 24rpx;
					color: #333333;
					flex: 1;
				}
				.g_pay{
					font-size: 20rpx;
					color: #999999;
				}
			}
			.g_price{
				color: #333;
				font-size: 28rpx;
				font-weight: 600;
				width: 160rpx;
				text-align: right;
				white-space: nowrap;
				.small{
					font-size: 24rpx;
				}
				// .price{
				// 	text-decoration: line-through;
				// }
			}
		}
		.order_youhui{
			height: 54rpx;
			background: #FBF8FE;
			border-radius: 8rpx;
			align-items: center;
			display: flex;
			justify-content: space-between;
			font-size: 20rpx;
			color: #8615E1;
			padding: 0 20rpx;
			.left{
				display: flex;
				align-items: center;
				image{
					width: 20rpx;
					margin-right: 10rpx;
					display: block;
				}
			}
		}
		.time{
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin: 10rpx 0;
			.p_time{
				font-size: 20rpx;
				color: #999999;
			}
			.p_daojishi{
				display: flex;
				align-items: center;
				color: #AF141D;
			}
			view{
				font-size: 20rpx;
				color: #333333;
				.small{
					color:#AF141D;
					font-weight: 600;
				}
				.price{
					font-size: 32rpx;
					color:#AF141D;
					font-weight: 600;
				}
			}
		}
		.btns{
			display: flex;
			justify-content: flex-end;
			margin-top: 16rpx;
			view{
				width: 122rpx;
				height: 46rpx;
				border-radius: 8rpx;
				border: 2rpx solid #9300EA;
				font-size: 24rpx;
				color: #8615E1;
				margin-left: 20rpx;
				line-height: 46rpx;
				text-align: center;
			}
			.long{
				width: auto;
				padding: 0 10rpx;
			}
			.bg{
				background: #8615E1;
				color: #FFFFFF;
			}
		}

	}

	.loading_message {
		color: #0062CC;
		padding: 20upx;
		text-align: center;
	}

	.loading_message image {
		height: 50upx;
		width: 50upx;
	}
</style>